package ru.bragnikita.utils.swing.widget.field;

import org.apache.commons.lang3.ObjectUtils;

/**
 * @author Nikita.Brazhnikov
 */
public class TextField extends AbstractField{

    public TextField(String id, String name) {
        super(id, name);
        setLength(5);
    }

    @Override
    public String getAsString(Object value) {
        if (value instanceof String)
            return (String) value;
        return ObjectUtils.toString(value, "");
    }

    public TextField withLength(int length) {
        setLength(length);
        return this;
    }
}
